package com.smartlbs.baseframe.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtils {
	
	/**
	 * @param time
	 * @return 年月日时分
	 */
	public static String dateTostr(Date time){
		SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm");
		String format2 = format.format(time);
		return format2;
	}
	public static String dateTostr(Date time,String simple){
		SimpleDateFormat format=new SimpleDateFormat(simple);
		String format2 = format.format(time);
		return format2;
	}
	
	/**获得 明天的日期 年月日
	 * @param time
	 * @return 
	 */
	@SuppressWarnings("deprecation")
	public static String getTimes(String time){
		SimpleDateFormat format= new SimpleDateFormat("yyyy-MM-dd");
		try {
			Date date = format.parse(time);
			int dayup=date.getDate()+1;
			int year = date.getYear();
			int month = date.getMonth();
			Date date2 = new Date(year, month, dayup);
			String format2 = format.format(date2);
			return format2;
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			
		}
		return"";
	};
	
	/**年 月。日 时：分
	 * @param date
	 * @return
	 */
	public static String dateTostrmm(Date date){
		int minutes = date.getMinutes();
		int seconds = date.getSeconds();
		int hours = date.getHours();
		if(seconds>0){
			minutes++;
		}
		int day = date.getDate();
		int month = date.getMonth();
		int year = date.getYear();
		Date date2=new Date(year, month, day, hours, minutes);
		SimpleDateFormat format=new SimpleDateFormat("YYYY-MM-dd HH:mm");
		return format.format(date2);
		
	}
	/**	
	 * @param date
	 * @return 年月日的string
	 */
	public static String dateTostrday(Date date){
		SimpleDateFormat format=new SimpleDateFormat("YYYY-MM-dd");
		String format2 = format.format(date);
		return format2;
	}
	 public static Date strTodate(String time) throws Exception{
		 SimpleDateFormat format =new SimpleDateFormat("YYYY-MM-dd hh:mm");
		 return format.parse(time);
	 }
}
